$(function(){
    $('.menu-item').click(function(){
        if($(this).attr('data-href')!=''){
            var url=$(this).attr('data-href');
            if(url.substr(0,7).toLowerCase() == "http://"||url.substr(0,8).toLowerCase() == "https://"){
                if(top.location!=self.location){
                    window.parent.location.href=url;
                }
                else{
                    location.href=url;
                }
            }
            else{
                if(url.substr(0,1).toLowerCase()=='/'){
                   if(top.location!=self.location){
                        window.parent.location.href=getRootPath()+url;
                   }
                   else{
                    location.href=getRootPath()+url;
                   }
                }
                else{
                    if(top.location!=self.location){
                        window.parent.location.href=getRootPath()+'/'+url;
                    }
                    else{
                        location.href=getRootPath()+'/'+url;
                    }
                }    
            } 
        }
        else{
            var sub_index=$(this).attr('data-index');
            $('.menu').hide();
            $('.sub-menu').hide();
            $('.sub-menu-'+sub_index).show();
            $('.title img').hide();
            $('.title i').show();
            $('.title lable').html($(this).find('lable').html());
        }
    });
    $('.title i').click(function(){
        $('.title lable').html('目录');
        if(top.location!=self.location){
            
            $('.title img').show();
        }
        $('.title i').hide();
        
        $('.sub-menu').hide();
        $('.menu').show();
    });


    if(top.location!=self.location){
        $('.title img').show();
    }


    $('.title img').click(function(){
        $('.index-iframe', window.parent.document).animate({left:'-'+(Number($(window.parent).width())*0.8)+'px'},500,function(){
            
        }); 
        setTimeout(function(){
            $('.zhezhao', window.parent.document).hide();
        },499);
    });
})